package com.dkd.manage.mapper;

import com.dkd.manage.annotation.AutoFill;
import com.dkd.manage.constant.OperationType;
import com.dkd.manage.pojo.dto.PolicyQueryListDto;
import com.dkd.manage.pojo.entity.Policy;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface PolicyMapper {


    /**
     * 分页查询策略列表
     * @param policyQueryListDto
     * @return
     */
    List<Policy> list(PolicyQueryListDto policyQueryListDto);


    /**
     * 新增策略
     * @param policy
     * @return
     */
    @AutoFill(OperationType.INSERT)
    Integer add(Policy policy);

    /**
     * 修改区域
     * @param policy
     * @return
     */
    @AutoFill(OperationType.UPDATE)
    Integer edit(Policy policy);

    /**
     * 根据id查询策略
     * @param id
     * @return
     */
    @Select("select policy_id, policy_name, discount, create_time, update_time, create_by, update_by " +
            "from tb_policy where policy_id = #{id}")
    Policy getPolicyById(Long id);

    /**
     * 根据id删除策略
     * @param ids
     * @return
     */
    Integer deletePolicyById(@Param("ids") Long[] ids);
}
